//
//  NativeEncrypt.m
//  gdemm
//
//  Created by 乔明超 on 16/5/6.
//  Copyright © 2016年 Goldencis. All rights reserved.
//

#import "NativeEncrypt.h"
#import "fileenc.h"
#import "transenc.h"

@implementation NativeEncrypt
+ (BOOL)isEncryptedFile:(NSString *)filePath{
    const char *path = [filePath cStringUsingEncoding:NSUTF8StringEncoding];
    BOOL isEncry7 = gdsb_getenckeys(path, NULL, NULL);
    BOOL isEncry8 = docte_getenckeys(path, NULL, 0);
    return isEncry7 && isEncry8;
}

+ (BOOL)decrytFileFromPath:(NSString *)fromPath toPath:(NSString *)toPath{
    const char *from    =   [fromPath cStringUsingEncoding:NSUTF8StringEncoding];
    const char *to      =   [toPath cStringUsingEncoding:NSUTF8StringEncoding];
    if (!gdsb_getenckeys(from, NULL, NULL)) {
        BOOL isSuccess = gdsb_decrypt_to(from, to, NULL, 0);
        return isSuccess;
    }else {
        BOOL isSuccess = docte_decrypt_to(from, to, NULL, 0);
        return isSuccess;
    }

}
@end
